# Optimize multiple attributes

**URL:** <https://forum.finsweet.com/t/optimize-multiple-attributes/2008>\
**Category:** Attributes\
**Created:** [October 5, 2023, 1:21pm UTC](https://forum.finsweet.com/t/optimize-multiple-attributes/2008 "2023-10-05T13:21:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chintan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/chintan/32/142_2.png) [@chintan](https://forum.finsweet.com/u/chintan)\
**Post date:** [October 5, 2023, 1:21pm UTC](https://forum.finsweet.com/t/optimize-multiple-attributes/2008/1 "2023-10-05T13:21:04Z")

</div>

Hi there,

Live site: [Top Tech Jobs in Engineering, Programming, Design, Marketing, Sales and more | Tech Ladies](https://www.hiretechladies.com/jobs)

We have multiple filter, nest, load, static attributes. We’ve custom script as well to sequence it all(load \> nest \> filter \> static). It takes a fair 2-4 seconds to load filters even with good connection.

Do you recommend some way to optimize it or speed up the filters as soon as possible.

Custom script:

```auto
<script>
// ⭐ NEST BEFORE FILTER ⭐

window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.push([
  "cmsload",
  (listInstances) => {
    window.fsAttributes.cmsnest.init();
    window.fsAttributes = window.fsAttributes || [];
    window.fsAttributes.push([
      "cmsnest",
      (listInstances) => {
        window.fsAttributes.cmsfilter.init();
      }
    ]);
  }
]);
</script>

```

Have custom script to count items per filter and update whenever any filter is applied - [https://8n8qxy.csb.app/jobs.js](https://8n8qxy.csb.app/jobs.js)

TIA!

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [October 6, 2023, 10:06am UTC](https://forum.finsweet.com/t/optimize-multiple-attributes/2008/2 "2023-10-06T10:06:25Z")

</div>

Hey @chintan! Are you using the CMS Load speed boost to load your items?

Regarding the count items per filter, can you please try this code?

```js
setTimeout(() => {
  window.fsAttributes = window.fsAttributes || [];
  window.fsAttributes.push(['cmsfilter', function (filterInstances) {
    console.log('filter loaded');

    const [filterInstance] = filterInstances;
    const filtersData = filterInstance.filtersData;

    const updateResults = (filter) => {
      const elements = Array.from(document.querySelectorAll('[fs-cmsfilter-field]')).filter(
        (element) => element.textContent.trim() === filter.filterName
      );

      elements.forEach((element) => {
        const resultsTextElement = element.nextElementSibling?.querySelector('.results-text');
        if (resultsTextElement) {
          resultsTextElement.textContent = filter.filterResults;
        }
      });
    };

    filtersData.forEach(updateResults);

    filterInstance.listInstance.on('renderitems', (renderedItems) => {
      console.log('test', renderedItems);
      filtersData.forEach(updateResults);
    });
  }]);
}, 2500);

```

---

<div class="post-metadata">

**Author:** ![chintan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/chintan/32/142_2.png) [@chintan](https://forum.finsweet.com/u/chintan)\
**Post date:** [October 9, 2023, 10:10am UTC](https://forum.finsweet.com/t/optimize-multiple-attributes/2008/3 "2023-10-09T10:10:56Z")

</div>

Hi @Support-Luis ! yes, I’m using the speed boost.

Any changes required in the defer/async tags in the script loading 👇?

 ![Cleanshot_006854@2x](https://europe1.discourse-cdn.com/flex013/uploads/finsweet1/original/2X/8/8cc6f71c4788971ad457339c28ffe81770a2e95a.png)

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [October 9, 2023, 5:19pm UTC](https://forum.finsweet.com/t/optimize-multiple-attributes/2008/4 "2023-10-09T17:19:11Z")

</div>

Hey @chintan! You should not have both `async` and `defer` tags on the scripts. I recommend you use the ones provided in the docs.

Apart from that I am afraid there is not much we can do script-wise, try to optimize your items being loaded as much as you can by compressing images and loading only the info that is needed to the item cards
