Back to all posts

JS DOM Best Practice: Load js only if specific select is available


const dom_element = $( '#dom-element' );
// Checking is there any element with "#dom-element" ID
if ( typeof ( dom_element ) != 'undefined' && dom_element != null ) {
    //run your code
}