# Bootstrapping Prototype to allow simple widgets?

**URL:** <https://www.ruby-forum.com/t/bootstrapping-prototype-to-allow-simple-widgets/178546>\
**Category:** Rails\
**Created:** [November 6, 2009, 9:13am UTC](https://www.ruby-forum.com/t/bootstrapping-prototype-to-allow-simple-widgets/178546 "2009-11-06T09:13:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrizbot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a87d85/32.png) [@chrizbot](https://www.ruby-forum.com/u/chrizbot)\
**Post date:** [November 6, 2009, 9:13am UTC](https://www.ruby-forum.com/t/bootstrapping-prototype-to-allow-simple-widgets/178546/1 "2009-11-06T09:13:43Z")

</div>

Hi.

I am trying to create a simple widget that people can add to their  
site with one script tag, like the following:

The action is an RJS that renders some HTML at that spot (like a  
widget):

page.insert\_html :top, :widget\_div, :partial =\> ‘widget\_partial’

The issue is that the regular Prototype libraries are not included  
yet, so there is an error when it tries to get ‘element’.

If I include the Prototype libraries in one of my own test pages it  
works the way it should, but I can’t depend on someone adding those  
libraries and want to try to make it as ‘drop in’ as possible.

Any thoughts on how I can ‘bootstrap’ Prototype in this type of  
scenario? Does anyone have tips on how to achieve something like this  
in another way?

Thanks in advance for any help.

---

<div class="post-metadata">

**Author:** ![chrizbot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a87d85/32.png) [@chrizbot](https://www.ruby-forum.com/u/chrizbot)\
**Post date:** [November 6, 2009, 9:18am UTC](https://www.ruby-forum.com/t/bootstrapping-prototype-to-allow-simple-widgets/178546/2 "2009-11-06T09:18:59Z")

</div>

On Nov 6, 2:01 am, chrizbot [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> page.insert\_html :top, :widget\_div, :partial =\> ‘widget\_partial’

Well a simple solution would be for the output of your action to  
include prototype. Why not just tell people that they have to add 2  
script tags, one for prototype, one for your thing? (people don’t need  
to install anything, google hosts copies of prototype that anyone can  
link to). One think to consider is that including prototype might  
break some people’s websites (if they use a js library that conflicts  
with prototype).

Fred
