Every responsive website development tutorial recommends using the display:none
CSS property to hide content from loading on mobile browsers so the website loads faster. Is it true? Does display:none
not load the images or does it still load the content on mobile browser? Is there any way to prevent loading unnecessary content on mobile browsers?
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
The answer is not as easy as a simple yes or no. Check out the results of a test I recently did:
So after digging further I found this, which explains how each browser handles loading img assets based on css display: none;
Excerpt from the blog post:
use
<img srcset>
http://www.webdesignerdepot.com/2015/08/the-state-of-responsive-images/
No.The image will be loaded as usual and will still use the user’s bandwidth if you are considering the mobile phone user bandwidth saving.What u can do is to use media query and filter the devices that you want your image to be loaded.Your image must be set as a background image of a div,etc and NOT an tag since the the image tag will load the image regardless if the screen size and the media query set.
we're talking about images not loading on mobile, right? so what if you just did an @media (min-width: 400px){background-image:thing.jpg}
wouldn't it then only look for the image at above a certain screen width?