How to Optimize Open Graph Meta Tags for Javascript

Social Media Sharing

Open Graph Rendering For Rich Social Snippets


Attract social media users effortlessly and drive traffic to your website.

Thousands of potential customers are ready to be hooked on social media platforms—all it takes is … Open Graph tags. Get your posts to stand out in just a few clicks.

Sharable URL Snippets

JavaScript Blocks Open Graph and Leaves You with a Flat URL

The reason for this is that social media bots can’t render JavaScript.

Open Graph, injected through AJAX, is a set of meta tags that rules how the properties of a URL (e.g., blogs or landing pages) are shown when shared on social media platforms. Think of it as the content’s preview in the form of an image, a title, and a short description. To display rich previews, social media bots need to access your Open Graph tags—which is impossible when using libraries like React Helmet or Vue Meta to add them to your page. If you don’t optimize for this, users will only see an unappealing, unoptimized URL snippet.

open graph tags for javascript

Better Website Performance

SSR Is Expensive and Risky

Server-Side Rendering (SSR) may be the popular solution to fix this problem, but the costly investment isn’t worth it for an enterprise-size website that hosts dynamic content. For starters, it can take months—and cost you $72k or more in school fees for your team to figure out a functional SSR solution. 

In addition, as your website grows, you’ll require ongoing optimization and maintenance, which means more money, time, and skilled resources.

Furthermore, every time you make changes such as updating meta titles or changing a URL—your servers must render all of the Open Graph content again. Now imagine when you update content regularly and on a large scale. You can easily overload your servers, which affects your website performance.

Flawless Social Sharing 

Social Sharing with SEO Benefits

Compared to SSR, using Prerender to enable social sharing is much more affordable and scalable. Our solution is built to render web JS files into their HTML versions in advance, giving social media bots unrestricted access to the Open Graph tags. This way, all your intended web content assets will show up.

In addition, if you make any changes to the page, social media crawlers don’t have to render the whole page from scratch. We do the heavy lifting by dynamic caching, so you can offer a flawless social media sharing experience.


optimize open graph tags

No More Unoptimized URLs

Poor social sharing can harm your brand. Make the right impression.

Get started with 1,000 URLs free.

We Help Clients Everywhere in the World!

Prerender currently serves 2.7 billion web pages to crawlers.
Trusted by 65K businesses across the globe.

Social Media Sharing FAQs

Learn about Prerender, technical SEO, and JavaScript on our dedicated FAQs page.


Open Graph (OG) tags are a markup protocol social media platforms use to generate rich page previews when a link is shared on their platforms.

Developers can add these tags in the head section of the page to specify titles, descriptions, images, and other relevant information—turning URLs into rich objects when shared to improve social media reach and engagement.

Implementing and optimizing your open graph tags help you improve your social posts’ click-through rate (CTR) by:

  • Making them have a stronger presence on your audience’s screen
  • Display a more engaging and on-brand image
  • Show an enticing title that piques the audience’s curiosity

It would also help reach a wider audience as people are more likely to share a rich link than a plain URL.

Because single-page applications (SPAs) don’t refresh the page on user navigation, they need to deliver their meta tags dynamically using tools like React Helmet or Vue Meta. This includes open graph (OG) tags. However, social platforms can’t render JavaScript, making it impossible for them to access your OG information.

Prerender generates a snapshot of your fully rendered page – including meta tags like OG – and delivers it to social platforms on request, allowing them to display your links as rich objects.

Fix OG tags issues with Prerender for free!