You may be thinking ” whats the point? ” and you might be right. I’m not saying this is how is should work, more of a concept, how it would work, and its benefits.
How it works / Benefits
You would use this the same way you would for Css, but with the exception of two media types to choose from, screen, for desktop computers and handheld, for mobile devices. As you can see from the two media types allowed, I think this would be good for use when different scripts are need for desktop browsers and mobile browsers on tablets, mobile phones etc. So your markup might look something like this:
You can also comment out scripts that are not used (during testing etc) so in the following only the first script would be loaded in the following:
/** @import url="http://localhost/jmedia/js/mobile.js"; //@import url="http://localhost/jmedia/js/script2.js"; */
You would set up your markup something like this adding media=”screen” or media=”handheld” to the appropriate script tag and simply listing each script required on its own line:
And then to use the jMedia Plugin you would simple do any of the following:
I’ve created a basic example you can download here. Try it out and have a play around.
As this plugin is simple and basic it may not also not work on every mobile device (there is quite a lot of browsers and mobile devices out there!). The plugin has also not been tested in every browser, so it may not work in some of them, again, its only a concept, for now possibly.
This article shows a concept of how the media attribute would work if it would be used on script tags. It could be used the load scripts that are only needed for desktop browsers or mobile browsers. It may never be used and I can see why but I thought it would be an interesting concept to work on.