Script to lazy load images inspired by Google AMP technology
Google AMP is great but it is too strict and it is difficult to implement on existing sites. RAMPT speeds up your load time but it is easier to implement.
Insert the content of rampt.min.html file in the head tag of your site and insert the following script above the closing body tag
<script>
setup_rampt_imgs();
</script>
- Replace img tags with rampt-img
- Add width and height attributes
- Add a layout attribute, the following options are options are available:
- fixed: Doesn't resize the image
- responsive: Resize images to fit their container, width and height attributes do not need to match the exact width and height, the script just need that values to calculate the aspect ratio
This script uses Intersection Observer API, which is available on some browsers only To use it on more browsers you can insert a Intersection Observer polyfill above the RAMPT script tag
This script improves image loading but to optimize the site additional steps are necessary. Please visit our blog post for more information
MIT © Inflow