Mink Machine

Media queries and JavaScript

Mobile development and responsive design are all the rage these days and media queries are mentioned everywhere. It’s a CSS3 extension of the media types frequently used in HTML4 and CSS2. The following (very simplified) example hides an element if the browser device has a max width of 500 pixels.

@media (max-device-width: 500px) { .sidebar { display: none; } }

This is of course only the tip of the iceberg. There are tons of resolutions and variations to consider (for instance have a look at Andy Clarke’s Hardboiled CSS3 Media Queries), media queries are not supported by IE8 or older (live with it) and so on. But when used correctly, media queries can be a powerful tool.

However, media queries are indeed a nice asset when it comes to CSS, but unfortunately they will not prevent the browser from downloading many other things which may be superfluous on mobile devices.

Since many external scripts are large, this could be a problem. For instance, the minified and Gzipped version of JQuery is about ten times smaller in filesize than the regular version. It could also download a lot of images which may be unused on certain devices.

It would be nice to have a media query equivalent for JavaScript and other resources. There are some work-arounds, such as the one described by Peter-Paul Koch in Combining media queries and JavaScript, but I hope this area will improve in the future.

Related posts

Comments

No comments yet.

Leave a reply

Your email address will not be published. Required fields are marked *

Featured stories

The fairytale castles of Sintra

The fairytale castles of Sintra

"The Portuguese town of Sintra is famous for many beautiful castles. Palácio Nacional da Pena is arguably the most stunning of the lot. "
Aliens in Nevada and New Mexico

Aliens in Nevada and New Mexico

"We turned around and went down another dirt road, past countless Joshua trees until our car was covered in dirt and we finally arrived at the Front Gate of Area 51."
Having champagne in Champagne

Having champagne in Champagne

"We roamed the damp and chilly tunnels and stumbled upon a large barrel delivered by Napoleon himself."
Bunker safari

Bunker safari

"The area contains 54 excavated bunkers along with gun emplacements, scattered around the town’s most visible landmark."
Sessions in Seville

Sessions in Seville

"I end my journey in front of the tomb of Columbus, located inside the world’s largest Gothic cathedral."
Conquering Machu Picchu

Conquering Machu Picchu

"A life-long dream came true this morning, as I stood upon the mountain looking down at Machu Picchu. I felt like some strange mix between Indiana Jones and a small boy, gazing down upon the final treasure of the Incas."

Instagram

Seville
Venice
Fever Ray
Rome
Basel
Kuala Lumpur