prgrmr
prgrmr

Reputation: 852

Developing third party widget- Angular vs jQuery vs plain old JS

I am planning on creating a simple embeddable widget, think of something like Google ads or Facebook like box. Anyone can drop the widget in their website and the I will read a few params to load some data from my servers.

In the past I have used jQuery to make the API calls, templating and DOM manipulation and it has worked pretty neat.

I am wondering if I should use something like Angular or stick with jQuery or vanilla JS.

Appreciate your feedback.

Upvotes: 1

Views: 562

Answers (2)

Alexus
Alexus

Reputation: 1973

I personally like the jQuery-UI's concept for creating custom widgets. Which is pretty easy to learn and understand. You can create your own widget or extend any of the already existing widgets (like progressbar, draggable,droppable ).

$.widget( "widget.my_widget", {
    options: {  // Default options.
        value: 0
    },
    _create: function() {
        this.element.addClass( "my_widget" ).text( this.options.value );
		console.log(this);
    }
});

var my_widget = $('#widget').my_widget({
	value : 1
})
.my_widget{
	text-align: center;
	border:1px solid #000;
	width:20px;
	height: 20px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.3/jquery-ui.min.js"></script>


<div id="widget"> </div>

Upvotes: 2

Vladimir Drenovski
Vladimir Drenovski

Reputation: 300

I would suggest using Vanila JS so the widget wont depend on other frameworks, thus making it usability easier. If your goal is to enable everyone to just drop it in their website you need to take into consideration that different frameworks might be used by different developers and making a specific one required for the widget has a high probability of setting people off. In few words Vanila JS is the one thing that is the same in all other frameworks, therefore its your best option.

Upvotes: 1

Related Questions