Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Inject script programatically results in error 500 (LinkedIn follower plugin)

I want to insert the LinkedIn Follow Company Plugin, but only inject it, if the user has given consent. So instead of putting in the script tags directly, I have a banner, asking for consent and if the checkbox is checked the following function runs:

function injectLinkedin() {
  var linkedin_container = document.querySelector('#linkedin-follow-plugin');

  var script = document.createElement("script");
  script.setAttribute("src", "https://platform.linkedin.com/in.js");
  script.setAttribute("type", "text/javascript");
  script.setAttribute("async", "false");
  script.textContent = 'lang: de_DE';
  script.onload = function(){
      console.log('li');
  };
  linkedin_container.appendChild(script);

  var script2 = document.createElement("script");
  script2.type = "IN/FollowCompany";
  script2.setAttribute('data-id' , '1234');
  script2.setAttribute('data-counter' , 'bottom');
  script2.onload = function(){
    console.log('li2');
  };
  linkedin_container.appendChild(script2);
}

But that way LinkedIn responds with an error 500 for https://platform.linkedin.com/in.js

Don't see why/how linkedin can see how the code gets loaded. Putting in the script tags directly it works fine. And, strangely, this error is not on my local machine but only on the live server.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!