Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 661275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:14:58+00:00 2026-05-13T23:14:58+00:00

I am looking to create a javascript widget that can be hosted on other

  • 0

I am looking to create a javascript “widget” that can be hosted on other sites. For example. I want to host the javascript code on my site:

http://scripts.mysite.com/mywidget.js

(Think of it like Google Analytics).

Basically I want to distribute data via this javascript. But what I am unsure of is:

  • Are the rules different for development when creating a javascript for another site (cross site)
  • Are there any websites that explain these differences?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:14:58+00:00Added an answer on May 13, 2026 at 11:14 pm

    I would try to:

    1. Make it configurable

      • Load external stylesheets?
      • Where do I find resources I need? (images, stylesheets)
      • What layout/size should I have?

      By doing this you let the user decide if he wants your widget to automatically load the stylesheet, or if he wants to host it himself. If he does, he can also update the styles to better fit the page the widget resides on.

    2. Provide a wizard for generating a snippet of code to include on the page
      • Ensures that even moderately technical users can utilize your widget
    3. Make it light-weight
      • Serve everything minified and compressed
      • Serve with cache-headers, e-tags, last-modified and all other useful headers you can think of. This will both reduce the load on your servers as well as make your widget more responsive.
      • Try to avoid dependencies on libraries, or check if they are loaded on the page where the widget is used before loading them
    4. Be wary of conflicts
      • Prototype uses $, and so does jQuery. If your widget depends on Prototype, and the page it is hosted on uses jQuery without noConflict-mode, problems WILL arise
      • Do not clobber the global namespace!
        • If you don’t want anyone to interact with your widget, put it in a self-executing function in a closure and don’t create any global variables at all
        • If you want users to be able to interact with your widget, say for adding event listeners and such, claim a single global variable, let’s say ExampleComWidget as an object literal and put your methods there. User’s could then interact like: ExampleComWidget.addListener('update', callback);
    5. Use clever markup

      • Be sure to use scoping on your classes and ids, to avoid conflicts as much as possible

        I.e. if your company’s name is example.com, you could use classes like: com-ex-widget-newsItem

      • Validate your markup! You do not want to break a user’s site
      • Semantic markup is fine, but you might want to avoid <h1>-tags, since they have especially high ranking in SEO. You could probably get by with using <h4> and less. This bullet might be a bit off. When in doubt, it’s much better to use semantic markup than not.
    6. Fetch data from your site by inserting script elements
      • This is a fool-proof way to ensure that you get around the same-origin restrictions.
      • Attach an onload-listener to the script element to know when the data is ready, or use jsonp
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 374k
  • Answers 374k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use def YourNotifierClass < ActionMailer::Base include ActionView::Helpers::DateHelper ...… May 14, 2026 at 7:59 pm
  • Editorial Team
    Editorial Team added an answer Okay, I found it: $('.addthis_button').attr('addthis:url',shareURL); $('.addthis_button').attr('addthis:title',shareTitle); $('.addthis_button').attr('addthis:description',shareTitle); May 14, 2026 at 7:59 pm
  • Editorial Team
    Editorial Team added an answer It might be worth it if your database is I/O… May 14, 2026 at 7:59 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.