Add Instagram feed to Shopify without losing Site Speed

Add Instagram feed to Shopify without losing Site Speed

<div class="portfolio">
{% for block in section.blocks %}
  <div class="portfolio-item">
    <a href="{block.settings.post_link}" target="_blank">
      <div class="portfolio-item-overlay"></div>
      <img class="portfolio-item-image" src="{{ block.settings.ig_image | img_url: 'master' }}" alt="{{ block.settings.ig_image.alt }}" >
      <div class="portfolio-item-details fadeIn-bottom">
        <h3 class="portfolio-item-title">{{block.settings.title}}</h3>
      </div>
    </a>
  </div>
 {% endfor %}
</div>


{% schema %}
{
    "name": "Portfolio",
    "class": "portfolio-class",
    "blocks": [
        {
            "name": "Item",
            "type": "Instagram",
            "settings": [
                {
                 "type": "image_picker",
                 "id": "ig_image",
                 "label": "Upload Portfolio Image"
                },
                {
                "type": "text",
                "id": "title",
                "default": "Portfolio Title",
                "label": "Portfolio Title"
               },
              {
              "type": "url",
              "id": "post_link",
              "label": "Portfolio URL"
              }
            ]
        }
    ],

    
    "presets": [
        {
            "category": "Portfolio",
            "name": "Portfolio Feed"
        }
    ]
}
{% endschema %}

{% stylesheet %}


.portfolio {
    width: 100%;
    margin: 50px 0;
    display: inline-block;
}

.portfolio .title{
  color: #1a1a1a;
  text-align: center;
  margin-bottom: 10px;
}
  
.portfolio-item {
    position: relative;
    width: 31.33%;
    float: left;
    border: 5px solid #fff;
    margin: 1%;
    box-shadow: 3px 3px 50px 13px #0000001c;
}



/* This CSS for small Mobile*/
@media (max-width: 767px) {

  .portfolio-item {
    position: relative;
    width: 33.33%;
    float: left;
}

}

.portfolio-item a {
    display: flex;
}
  
.portfolio-item .portfolio-item-overlay {
    background: rgba(0,0,0,.7);
    position: absolute;
    height: 100%;
    width: 100%;
    left: 0;
    top: 0;
    display: block;
    bottom: 0;
    right: 0;
    opacity: 0;
    -webkit-transition: all .6s ease-in-out 0s;
    -moz-transition: all .6s ease-in-out 0s;
    transition: all .6s ease-in-out 0s;
}

.portfolio-item:hover .portfolio-item-overlay{
  opacity: 1;
}

.portfolio-item-image{
  width: 100%;
}

.portfolio-item-details {
  position: absolute;
  text-align: center;
  padding-left: 1em;
  padding-right: 1em;
  width: 100%;
  top: 50%;
  left: 50%;
  opacity: 0;
  -webkit-transform: translate(-50%, -50%);
  -moz-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  -webkit-transition: all 0.3s ease-in-out 0s;
  -moz-transition: all 0.3s ease-in-out 0s;
  transition: all 0.3s ease-in-out 0s;
}

.portfolio-item:hover .portfolio-item-details{
  top: 50%;
  left: 50%;
  opacity: 1;
}

.portfolio-item-details h3 {
    color: #fff;
    text-transform: uppercase;
    font-style: italic;
}


.fadeIn-bottom{
  top: 20%;
}

{% endstylesheet %}

{% javascript %}
{% endjavascript %}