Phate
Phate

Reputation: 6622

Is it possible to execute vanilla javascript before angular boot?

I want to execute a javascript snippet that check whatever the browser supports angular or not. In the second case the script will do a redirect towards a static html webpage.

My intent is not rely on polyfills to support outdated browsers, but give a nice UX anyway by inviting the visitor to access my website with a modern browser.

Is it possible?

Upvotes: 0

Views: 74

Answers (1)

Eliseo
Eliseo

Reputation: 58039

In your main.ts

//replace this
//    platformBrowserDynamic().bootstrapModule(AppModule)
//      .catch(err => console.error(err));

//by some like:

if (executeAjavaScriptFunction())
{
  platformBrowserDynamic().bootstrapModule(AppModule)
     .catch(error=>console.log(error))
}
else
{
  alert("improve your navigator");
}

Or you can also write in your .html some like

  <app-root>
   If you can't see the application visit www.myoldpage.com
  </app-root>

Upvotes: 1

Related Questions