The Goal:
If you don’t want something to load in the DOM on a certain screen size, you can use the following code to remove elements from the DOM entirely, vs hiding them, which still keeps them inside of the DOM.
Requirements:
- HTML
- jQuery
CodePen
This example shows the required files, HTML and jQuery markup.
See the Pen
Remove Elements Based on Window Size/Viewport w/ jQuery by Brittany Golden (@brittany-golden)
on CodePen.