-1

I am working with Node and React(NextJS) SSR based project, I have added createjs because I have javascript based animations, unfortunately it dosen't have NPM package so I download the minified js library and serving from local server, but after adding this library to HEAD after 20-30 seconds it gives response, when I tried this on plain HTML it takes just 20-30 miliseconds only to renponce. What should I do to minimize response time

componentDidMount(){

 this.checkLib()
}

checkLib(){

setTimeout(()=>{
   if(window.createjs){
    console.log('library is ready')
   }else{
    this.checkLib()
   }
},500)

}  


render(){
return(
   <Head>
          {(typeof window !='undefined')
          ? <script src='./../static/js/createjs.min.js' />
          :'' }
   <Head>
)
}
Amit Shakya
  • 962
  • 3
  • 16
  • 30

1 Answers1

0

I add global npm package it returns window and document object. It returns window object on DidMount event and It helps me to add library on initial level.

Amit Shakya
  • 962
  • 3
  • 16
  • 30