in Education by
So I'm using Supersized to scale my background images and that's all good and well. The problem is that if I want the image to look good at multiple resolutions, it should be big, e.g. 2000 px * 2000 px. But why should someone with a resolution of e.g. 800 * 600 need to download such a large image? So what I'd like to do is to have, let's say, 3 sizes of the image (1024 * n, 1680 * n and 2000 * n) and, depending on the resolution, the smallest possible of them would be sent to the user. Any thoughts on how I should implement this? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Using Javascript's window.screen.width will return you the actual pixel width of the screen, so then you can use a simple if statement to select which image you will use. if(window.screen.width < 1000) { image = "small.jpg"; } else { image = "large.jpg"; }

Related questions

0 votes
    When assigning a background color of a table cell on hover, the box shadow is covered. I have found ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    When assigning a background color of a table cell on hover, the box shadow is covered. I have found ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I have a list, and each item is linked, is there a way I can alternate the background colors for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 9, 2022 in Education by JackTerrance
0 votes
    I have a list, and each item is linked, is there a way I can alternate the background colors for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 8, 2022 in Education by JackTerrance
0 votes
    I have a list, and each item is linked, is there a way I can alternate the background colors for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 8, 2022 in Education by JackTerrance
0 votes
    I have a list, and each item is linked, is there a way I can alternate the background colors for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 6, 2022 in Education by JackTerrance
0 votes
    Thanks for helping. I am trying to develop a static carousel (it won't move, but it acts like one) that stretches ... screen (but hidden, so no scrollbar). Here is the markup:...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have created floating label in input field.In chrome view is working fine, but not properly viewed in ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How to remove the space between inline/inline-block elements? (41 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How to remove the space between inline/inline-block elements? (41 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How to remove the space between inline/inline-block elements? (41 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How to remove the space between inline/inline-block elements? (41 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I have hours trying to figure out how to avoid this bullet points at the bottom being cutted when the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I have hours trying to figure out how to avoid this bullet points at the bottom being cutted when the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    In a web application, is it acceptable to use HTML in your code (non-scripted languages, Java, . ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
...