This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 13582 - HTML5 suggestion: Elements of HTML section: Scripting and Document Metadata subsections
Summary: HTML5 suggestion: Elements of HTML section: Scripting and Document Metadata s...
Status: RESOLVED NEEDSINFO
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: Other All
: P3 normal
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: HTML WG Bugzilla archive list
URL: http://www.w3.org/mid/BLU0-SMTP1068F8...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-03 05:47 UTC by HTML WG bugbot
Modified: 2013-03-08 23:09 UTC (History)
8 users (show)

See Also:


Attachments

Description HTML WG bugbot 2011-08-03 05:47:48 UTC
public-html-comments posting from: Andrew Martin <andrew@martinone.co.uk>
http://www.w3.org/mid/BLU0-SMTP1068F87B5E7A69C392B78C98A4C0@phx.gbl

When using JavaScript libraries such as jQuery or MooTools, they currently need to be called from another file using an empty <script></script> element. It is not currently possible, however, for a browser to have such libraries pre-installed.

I would like to suggest the introduction of an empty <library> (<library /> in XHTML) containing the attributes:
name (required) - the library's name. Case insensitive.
minvers - the minimum version required
maxvers - the maximum version required
src - the URL of the library, if a suitable version isn't pre-installed, similar to <script>
type - just like <script>, the MIME type of the library. Defaults to "text/javascript".

For example, jQuery (at least 1.4) could be called using:
<library name="jquery" minvers="1.4" src="jquery-1.6.2.min.js" />

Thanks,
Andrew Martin
Comment 1 T.J. Crowder 2011-08-03 05:55:02 UTC
Rather than using a separate `library` tag, which causes backward-compatibility issues, if something like this were to be done I'd recommend doing it with attributes on the `script` tag, perhaps:

* `library` - The case-insensitive name of the library ("jquery", "dojo", "prototype", "YUI", etc.). This is the key attribute that triggers the "use bundled" behavior; it explicitly declares that it's acceptable for the browser to use its bundled version rather than fetching the given resource (and, of course, tells it which library to use).

* `modules` - (Optional) If the library is modular, the modules required.

* `minver` - (Optional) The minimum acceptable version.

* `maxver` - (Optional) The maximum acceptable version.

The browser must always supply the latest version of the given library it has within the given range. 

So for example:

`<script library="jquery" minver="1.5" src="jquery-1.5.2.min.js"></script>`

If the browser's latest is 1.6.2 (note the 6), it supplies that, because no maxver was given.

Completely backward-compatible, but has the necessary information if browser vendors start pre-bundling libraries.

-- T.J.
Comment 2 Henri Sivonen 2011-08-03 07:19:48 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are
satisfied with this response, please change the state of this bug to CLOSED. If
you have additional information and would like the editor to reconsider, please
reopen this bug. If you would like to escalate the issue to the full HTML
Working Group, please add the TrackerRequest keyword to this bug, and suggest
title and text for the tracker issue; or you may create a tracker issue
yourself, if you are able to do so. For more details, see this document:
<http://dev.w3.org/html5/decision-policy/decision-policy.html>.

Status: Rejected
Change Description: no spec change
Rationale: The proposed change fails to Degrade Gracefully in existing browsers. Also, it would add another element that runs scripts. Script execution is already hard enough that I think we shouldn't make changes that'd require implementors to give more elements the script execution (and presumbably parser blocking) nature.
Comment 3 T.J. Crowder 2011-08-03 08:28:40 UTC
The editor's response doesn't seem to have taken my comments (originally on the list, and then in this bug as they weren't copied originally) into account. Agreed that a `library` element is a non-starter, but semantics on `script` elements that explicitly provide information the browser can use but also degrades on browsers not offering the feature is something to think about.
Comment 4 Michael[tm] Smith 2011-08-04 05:16:49 UTC
mass-move component to LC1
Comment 5 Simon Pieters 2011-08-05 12:20:56 UTC
(In reply to comment #3)
> The editor's response doesn't seem to have taken my comments (originally on the
> list, and then in this bug as they weren't copied originally) into account.
> Agreed that a `library` element is a non-starter, but semantics on `script`
> elements that explicitly provide information the browser can use but also
> degrades on browsers not offering the feature is something to think about.

Reopen the bug if you think there is new information to consider.
Comment 6 T.J. Crowder 2011-08-05 12:32:31 UTC
The editor's response closing the bug addressed issues with the original proposal that were effectively identical to the issues I raised, and solved, in Comment #1 (and several days earlier on the mailing list, but my comments weren't copied over when the bug was logged).

The idea behind the original suggestion is sound (provide an explicit means of giving permission to browsers to use bundled libraries), but the mechanics were completely off-base.

Since the editor's response seems not to be informed by Comment #1, I'm reopening.

Addressing the editor's response:

> The proposed change fails to Degrade Gracefully in existing
> browsers.

With the changes from Comment #1, it would work on IE 5.5 if you could find a copy. :-)

> Also, it would add another element that runs scripts. Script execution
> is already hard enough that I think we shouldn't make changes that'd
> require implementors to give more elements the script execution (and
> presumbably parser blocking) nature.

With the changes from Comment #1, the `script` element is enhanced rather than adding a `library` element, solving this issue.

Regards,
--
T.J. Crowder
tj@crowdersoftware.com
Comment 7 Robin Berjon 2013-01-21 16:00:11 UTC
Mass move to "HTML WG"
Comment 8 Robin Berjon 2013-01-21 16:02:56 UTC
Mass move to "HTML WG"
Comment 9 Travis Leithead [MSFT] 2013-03-08 23:09:43 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are
satisfied with this response, please change the state of this bug to CLOSED. If
you have additional information and would like the Editor to reconsider, please
reopen this bug. If you would like to escalate the issue to the full HTML
Working Group, please add the TrackerRequest keyword to this bug, and suggest
title and text for the Tracker Issue; or you may create a Tracker Issue
yourself, if you are able to do so. For more details, see this document:


   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Additional Information Needed
Change Description: No spec change
Rationale:

I believe the general idea is sound and backwards compatible (which is really necessary for something like this). However, there are a number of pieces that are missing in order to land this as a new feature. Notably, the details in how a library can be installed, such that these new script element attributes take effect.

Some additional questions to ponder:
* Is there new API needed for a script library to register itself as such?
* Can new versions of a library auto-update the old versions?
* How do you install a library so that the name attribute can be associated with the library?
* How do you avoid collisions with different libraries registering for the same name? How do you deal with modules/sub-modules?
* How do the use cases for this feature relate to the browser's cache, the current practice of hosting libraries on CDNs, etc.
* What are the potential security implications?

I'd encourage you to consider writing this up as an extension specification to HTML. Here's some details to get you started: http://www.w3.org/html/wg/wiki/ExtensionHowTo

Thanks!