Is it possible to prevent (with jQuery) certain images from being loaded by a mobile device? Is there already a jQuery plugin?
For example: I want all images with the class “toobig” to not being loaded by a mobile device.
Thanks for your patience.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think there’s a way to prevent them from loading, but you could simply change the attributes of those elements in order to change what the browser attempts to load:
The above finds the relevant images, gives them a
heightandwidthof0(so the layout engine can flow/reflow the document quickly, and gives ansrcto, ideally, a small transparent image file. Of course, you could simplyremoveAttr('src'), if you prefer.The call to
hide()at the end is simply to ensure that, even with the size of0, there’s no way for the images to show in the document. In this caseremove()could, of course, be used instead.