четверг, 28 апреля 2011 г.

Пишем свой Javascript Фреймворк.

Здравствуйте,
И так, я не так уж и много статей видел в интернете о том как создать свой фреймворк в Javascript, и поэтому хочу начать свой цикл статей в которых мы будем постепенно создавать свой фреймворк.
Наш фреймворк будет аналогом известного фреймворка JQuery. Конечно же копией JQuery это не будет (не факт даже что будет полностью кроссбраузерный), так как суть будет просто в том что бы представить как можно создать похожий собственный фреймворк. Ну а дальше если у вас будет необходимость в создании собственного фреймворка, то вы уже сами сможете довести его до ума.

Приступим.
1. Как работает поиск элементов в JQuery
Насколько известно JQuery использует движок селекторов под названием Sizzle
Кстати: Движок Sizzle и JQuery имеют одного автора (John Resig)

Мы тоже будем использовать  этот движок. Поэтому перейдите на сайт sizzlejs.com и скачайте себе этот движок. Скачав движок подключите его к вашей странички. Теперь создайте один JS файл и назовите его к примеру framework.js И его тоже подключите к страничке (страничку назовем index.html)

Вот как должна выглядеть index.html:

<html>
<head>
<script type="text/javascript" src="sizzle.js"></script>
<script type="text/javascript" src="framework.js"></script>
</head>
<body>
</body>
</html>

Все, дальше мы будем работать исключительно с файлом framework.js, а index.html нам нужна будет для тестирования функций фреймворка.

На этом первый урок закончен,  в следующем уроке мы создадим функцию для получения элементов, и класс нашего фреймворка.

4 комментария:

  1. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools
    Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton
    of engaging advice and insight into front-end technologies. Even more obvious is his passion
    for open source contribution and trial-and-error development, making his blog one of the
    most honest and engaging around.
    Website: davidwalsh.name

    ОтветитьУдалить
  2. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    ОтветитьУдалить
  3. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    ОтветитьУдалить
  4. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    ОтветитьУдалить