Skip to content

Remove default type="text/javascript" from script tag wrapper#14838

Closed
RamiNoodle733 wants to merge 1 commit intobokeh:branch-3.9from
RamiNoodle733:remove-default-script-type
Closed

Remove default type="text/javascript" from script tag wrapper#14838
RamiNoodle733 wants to merge 1 commit intobokeh:branch-3.9from
RamiNoodle733:remove-default-script-type

Conversation

@RamiNoodle733
Copy link
Copy Markdown

Summary

Removes the default type="text/javascript" attribute from script tag wrapper to follow HTML5 best practices.

Problem

In HTML5, the type="text/javascript" attribute is unnecessary since JavaScript is the default scripting language. Including it adds extra bytes to the HTML output without providing any benefit.

Changes

  • src/bokeh/embed/wrappers.py: Changed default type parameter from "text/javascript" to empty string
  • src/bokeh/core/_templates/script_tag.html.jinja: Updated template to only render the type attribute when it is non-empty

Benefits

  • Smaller HTML payload size
  • Follows modern HTML5 best practices
  • Cleaner output
  • Backward compatible - users can still explicitly specify type if needed

In HTML5, the type="text/javascript" attribute is redundant since
JavaScript is the default scripting language. This change removes the
default type attribute from the script tag template and makes it
conditional - only rendering when explicitly specified.

Changes:
- Changed default type parameter from "text/javascript" to empty string
- Updated template to only render type attribute when non-empty
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (branch-3.9@bab0266). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff              @@
##             branch-3.9   #14838   +/-   ##
=============================================
  Coverage              ?   91.28%           
=============================================
  Files                 ?      291           
  Lines                 ?    20997           
  Branches              ?        0           
=============================================
  Hits                  ?    19167           
  Misses                ?     1830           
  Partials              ?        0           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mattpap
Copy link
Copy Markdown
Contributor

mattpap commented Feb 6, 2026

Before submitting a PR, please create an issue, so that we can discuss the validity of an idea. Given you already submitted a PR, you need to associate an issue with it regardless.

@mattpap
Copy link
Copy Markdown
Contributor

mattpap commented Feb 6, 2026

There are a lot more cases of text/javascript in various parts of the codebase, thus it would be good for consistency sake, to apply the same treatment to all relevant cases. Besides this, tests need to be updated.

@RamiNoodle733 RamiNoodle733 closed this by deleting the head repository Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants