• Resolved andrei0x309

    (@andrei0x309)


    Is there a way to exclude specific selectors from tree shaking?
    I am using <amp-script> to dynamically add content similar to:

    let searchModalOpen = false;
    
    const showSearchModal = () => {
      if(!searchModalOpen) {
      searchModalOpen = true;
      const searchModal=document.createElement('div');
      searchModal.id="full-search-modal";
      searchModal.innerHTML =  '
    <button id="search-close-btn">X</button> 
    <form id="menu-search-from" role="search" method="get" class="search-form" action="${window.location.origin}">
    	<label style="display:none;" for="menu-search-input">Search</label>
            <input placeholder="Search" type="search" id="menu-search-input" class="search-field" name="s" autocomplete="off" />
            <input style="display:none;" type="submit" class="search-submit" value="search" />
    </form>
      </div>';
      document.getElementsByTagName("BODY")[0].appendChild(searchModal);
      //searchModal.classList.add('search-modal-open');
     
      document.getElementById('search-close-btn').addEventListener('click', closeSearchModal);
      //document.getElementById('menu-search-from').addEventListener('submit', searchAddSpinner);
      }
    };

    Is there a filter hook or something to use to exclude specific selectors? I can’t find any hook for this in the documentation.

    Thanks.

    • This topic was modified 5 years, 2 months ago by andrei0x309.
    • This topic was modified 5 years, 2 months ago by andrei0x309.
    • This topic was modified 5 years, 2 months ago by andrei0x309.
    • This topic was modified 5 years, 2 months ago by andrei0x309.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Exclude specific selectors from tree shaking’ is closed to new replies.