Last modified: 2009-07-28 00:54:17 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T21576, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 19576 - Remove the name attribute from header <a> tags
Remove the name attribute from header <a> tags
Status: CLOSED FIXED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
http://en.wikipedia.org/wiki/Kevin_Pi...
: patch
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-07-08 04:54 UTC by Laurence 'GreenReaper' Parry
Modified: 2009-07-28 00:54 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Removes the name attribute from the <a> of headers, the editing <textarea>, and Monobook's <a id="top"> (2.46 KB, patch)
2009-07-08 04:54 UTC, Laurence 'GreenReaper' Parry
Details
Removes the <a> entirely, moving the id to the header tag (764 bytes, patch)
2009-07-08 05:35 UTC, Laurence 'GreenReaper' Parry
Details

Description Laurence 'GreenReaper' Parry 2009-07-08 04:54:04 UTC
Created attachment 6305 [details]
Removes the name attribute from the <a> of headers, the editing <textarea>, and Monobook's <a id="top">

MediaWiki currently emits both name and id attributes for <a> tags used for headers. I believe the name should be removed, because it measurably increases the size of each article with headers for no good reason.

The name attribute used in this fashion appears to only be required for compatibility with Netscape 4, which does not recognize the id attribute for the purpose of jumping to a point in a page (based on the portion of the URL following the # symbol).

Netscape 4 is no longer in common or uncommon usage. It was removed from http://www.w3schools.com/browsers/browsers_stats.asp at the start of 2005 (when IE5 still had 10% of the market). All modern browsers recognize the id attribute for this function, as per the HTML 4.01 standard:
http://www.w3.org/TR/REC-html40/struct/links.html#anchors-with-id 

Removing the name attribute is easy. The savings are small but measurable - even for larger articles with high proportions of body text to headings - and I feel they outweigh the minor loss of functionality on an obsolete browser.

For example, the current featured article on the English Wikipedia, http://en.wikipedia.org/wiki/Kevin_Pietersen has the following size (gzip in parentheses):

With name attribute: 251,917 (48,002) bytes
Without name attribute: 251,061 (47,863) bytes
Reduction: 856 [0.3%] (139 [0.3%]) bytes

The relative savings are increased for languages which have long names/ids due to restrictions on the characters present in ids, and for shorter pages with several headings.

The name attribute on the editing textarea (<textarea name="wpTextbox1" id="wpTextbox1">) and Monobook's top anchor (<a name="top" id="top">) might also be removed, although the savings here will obviously be limited.
Comment 1 Laurence 'GreenReaper' Parry 2009-07-08 05:15:17 UTC
It might also be possible to place the id completely inside the <hX> tag, removing the <a id=\"$anchor\"></a> line completely for even more savings. However, I am unsure of the implications of this; in particular, whether callers of makeHeadline (only Parser::formatHeadings()?) may have added an id to $attribs in some circumstances.
Comment 2 Laurence 'GreenReaper' Parry 2009-07-08 05:35:57 UTC
Created attachment 6306 [details]
Removes the <a> entirely, moving the id to the header tag

Demonstrates the alternative approach mentioned in Comment #1.
Comment 3 Laurence 'GreenReaper' Parry 2009-07-09 04:33:48 UTC
Implemented by rememberthedot in r52963.
Comment 4 Laurence 'GreenReaper' Parry 2009-07-28 00:54:17 UTC
Reimplemented in r53577.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links