scottjehl / picturefill

A responsive image polyfill for <picture>, srcset, sizes, and more
http://scottjehl.github.com/picturefill/
MIT License
9.88k stars 1.07k forks source link

Is it possible to make the package work with SSR? #697

Closed aviramga closed 2 years ago

aviramga commented 7 years ago

Hi,

I am using NextJS (react ssr) and tried to use your package. There is an issue when trying to use it as it uses the window object.

How can I make it work in SSR?

Thanks!

Aziz-JH commented 6 years ago

Hi, I had the same problem and i fixed with process.browser.

polyfills.js

if (process.browser) {
  require('picturefill');
}

Best, Julian