I'm kind of an old-hat web developer, and I recently started work on a project that has some LinkedIn integration. I had never seen a script tag with a type like "IN/login" before, and have been trying to figure out what exactly that is/means.
Of course, I know that I can just copy and paste the code from the API documentation and I know that it works, but I'm the sort who also wants to know why and how it works.
The only thread I've found so far that directly addresses this style of script type attribute is this one:
https://developer.linkedin.com/forum/profile-plugin-stopped-working
where someone reports that this type value causes problems with a version of WordPress, and the problem is blamed on WordPress and the assertion is made that:
"we use the script node's type attribute to specify the type of plugin. The browser won't try to execute a script node with a type of anything other than "text/javascript". This allows us to convert these nodes into plugins without leaving behind a visible node, while still being entirely standards compliant (and even pretty semantic too)."
That first bit is the important bit for me, as it at least explains exactly what "IN/login" means. Great. But as for this being "entirely standards compliant," as far as I can tell, no, it most certainly isn't. The attributes of every HTML tag are pretty rigorously standardized and defined, as are the allowable values of those attributes. The specs:
http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.1
say that "type" for a script element is an attribute of type "content-type". "content-type" is in turn defined:
http://www.w3.org/TR/html4/types.html#type-content-type
...as a media type as per RFC2045/RC2046.
The salient part of all that is that a media type isn't something you're supposed to just make up. It's supposed to be unique, so that no two people happen to make up the same media type to describe two different types of data. You're right that most browsers and applications *probably* will ignore the content of a script tag with a totally made up media type, but I don't think it's a good idea to rely on that.
The fact that LinkedIn is doing this at all means that the developers who came up with the idea in the first place haven't read those RFC documents, and also probably don't know about this site:
http://www.iana.org/assignments/media-types/index.html
which is the official gigantic list of formally registered media types. That means that there's a chance that one day one of the plugin names might conflict with something else on that list, and that might cause interesting problems. Or not -- it's worth pointing out that "IN" isn't at all like the valid content types "application", "audio", "example", "image", "message", "model", "multipart", "text", and "video". The "IN" prefix seems to be along the same lines as having a ".microsoft" or ".apple" top-level domain name alongside ".com", ".net", ".edu", etc. -- i.e. commercializing/owning/branding something that was supposed to have only an informational meaning.
"IN" is also a poor choice because it's not very unique -- if it's OK for LinkedIn to define its JavaScript type this way, what happens if some other website happens to pick the same one? Suppose there were a network called "FriendInnovate" or something, and they also started using IN/ prefixes (thinking that "surely no one else has thought of this, so it should be totally fine"). Someone writes an app that works on both of them, and oh snap; LinkedIn's JavaScript is trying to parse FriendInnovate's and vice versa. Oops. This is why media types are supposed to be registered and standard.
So, in short, yes, it's possible to get away with using completely invalid values for all kinds of things in HTML, but no one should be claiming that this is in any way "standards compliant," and I strongly suggest that someone on the LinkedIn developer staff read the RFC's and the HTML specs and find a way of describing plugin types that actually is standards compliant.
~Felix.
- Log in to post comments
Thanks for the thorough writeup! Definitely refreshing to see a developer with such a unwavering and passionate disposition for standards. You sir, rock!
The proprietary
IN/Sharenotation was in place when I joined the team. That said, it's no excuse, but I still stand by my initial statement that it follows the standards. While we don't use a valid registered MIME-type, I think it still follows the standards. Nevertheless, there's definitely room for improvement in our framework. We don't intent to make something propriety (anyone remember fbml?), but we're trying to do something sufficiently unique that lets us easily supports a copy paste solution.What about something like
<script type="text/x-linkedin-share"></script>, which strictly follows thediscrete-type/subtypenotation.we could even build in reasonable support for custom namespacing:
we actually something like this for
data-namespacing:Thanks for the thought provoking, and humbling, feedback! Much appreciated.
- Eugene