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

Before

After

CodePen

This example shows the required files, HTML and jQuery markup.

Share This