You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
RequireJS はみんな使ってるらしーし、 何かかっこいいし、意識高そうだし、使っとくか! ・・・と、思って試しに使い始めてみたのですが、 自分が作るような小規模なものの場合、 大変な割に良い事あんまりないので使うのを止めました。 以下、忘れそうなのでその理由をメモって置きます。 基本的に、1枚のJSファイルが1モジュール、ファイル名がコードに影響する。それもあって、結合・圧縮は r.js という専用のツールが必要になる。Grunt の concat とか uglify とか使えない。 AMD の仕様では、「JSファイルのリストを順番通りに読み込み/実行する」ということができない。実際何が困ったかというと、分割した mocha テストケースを順番通りに実行できなくなったということ。結果は変わらなくても、順番通りに実行されないと結果が見辛いし、問題が起こった時に発見が難しい。ただしこれは
Introduction [UPDATE: This post has new 2015 followup] This is about managing dependencies in a well-tested client-side JavaScript codebase, how I got overwhelmed, and how I automated the pieces to make it Just work ™. The JavaScript world has grown a lot of tools for dependency management. I've dipped my toes into it into the past, but didn't really know much about it, especially on the client-si
January 10, 2013 Following the yesterday’s post. This time, using PhantomJS and Grunt. Testem does pick up PhantomJS and can run against it. But, maybe some people just want to use Grunt because they use Grunt for something else such as for making a build. Setting up directories First, let’s create two directories: app and test. ‘app’ holds the application and ‘test’ of course contains test stuff.
Optimize (Concatenate and Minify) RequireJS Projects by naorye · Published April 19, 2013 · Updated May 19, 2016 This article will demonstrate you how to concatenate and minify projects that are based on RequireJS. In this article I’ll use several tools that require Node.js. So, if you don’t have Node.js yet, install it here. Motivation A lot has been written already about RequireJS. This tool all
iammerrick Hi, I'm Merrick and I love code so much I married it. Can provide proof upon request. Please check out this example project to follow along, I'm sure it will help you make sense of the following babble. requirejs-plugin-integration-testing. It is important that your Require.js plugins are building properly. Following is an approach to test your plugins build step in the browser, along w
メモ。 いい加減やらないと行けないと思いつつ、二回ほど試して上手く行かなくて放置してたので再入門した。 ディレクトリ構成 ├── app.js ├── entities ├── libs │ ├── backbone-0.9.9-min.js │ ├── bootstrap-2.2.2-min.js │ ├── jquery-1.8.2-min.js │ ├── jquery-layout-1.3.0-30.77.js │ ├── jquery-ui-1.9.1.custom.js │ ├── jquery.jsPlumb-1.3.16-all.js │ ├── micro-log.js │ ├── moment-1.7.0-min.js │ ├── require-2.1.2-min.js │ └── underscore-1.4.3-min.js ├── main.js ├── mod
r.js RequireJS用のmoduleをビルドする際にはr.jsを使います。 build.js この時にビルド設定の記述に使用するのがbuild.jsでこんな感じで書きます。 簡単な例だとこんなの ({ baseUrl:'./src', dir : './build', paths:{ jquery:"../lib/jquery-1.8.2", text:'../lib/plugins/text', underscore:'../lib/underscore-1.3.3' } }) 動的なbuild.js build.jsはJSONではなくてJSです。 JSなので処理を書くことが出来ます。 例えば関数その場実行を含む下記のbuild.jsは、上記のものと同じ設定を表します。 ({ baseUrl:'./src', dir : './build', paths:(function ()
げりんぐすたーてっど うぃず りくわぃあーじぇーぇす ということで、社内勉強会でRequireJSの入門資料をこさえたのでシェア。 利用したデモファイルセット http://d.aho.mu/S4mh なんとなくRequireJSが動くセットです。スライド中のr.jsによるビルドコマンドや、gruntを利用したビルドも試せるようになっています。 おさえるべき要点 いくつかの要点だけ記事内に文字列でおこしておきまする。 モジュラーと依存関係 Webサイト → Webアプリ への流れが明確になってきてフロントエンドが複雑化してきている今、1つのJSファイルにつらつらとCSSのようなノリで書き連ねる時代は終わりつつあります。 ParisJS #10 : RequireJS このあたりについては、上記の素晴らしいスライドから、Figureを拝借しました。個々のJavaScriptの粒度が揃えてモジ
Referencing JavaScript. How should it be done? Is there an approach that works for module systems, package managers and project layouts? The following describes the approach in use by AMD/RequireJS and volo, but parts are found in other places like Node, CommonJS and Dojo. The following approach works well for browser-based, web development. Since browser-based development is the harder environmen
REQUIRE JS JSの非同期ローディングとモジュール化を行うライブラリ 公式サイト 詳しくは、RequireJS実践編を参照 下記順番で読み込み(config-require.jsは自作。名前はなんでも良い) <script src="config-require.js"> <script data-main="main" src="require.js"> 非同期ローディングについて 下記を参考にconfig-require.jsを作成 設定値の詳細はこちらを参照 var require = { deps: ["some/module1", "my/module2", "a.js", "b.js"], callback: function(module1, module2) { //This function will be called when all the dependen
I've spent a lot of time trying to figure out which Javascript script loading framework to use. RequireJS or HeadJS. I still don't have an answer. Neither website refers to each other. In general To me, it's important to be able to load and execute some Javascript before downloading Javascript modules that aren't needed to render the initial screen. Makes for a more responsive behaviour and gets p
enchant.jsプログラミングでRequireJSを使うとなにが嬉しいの?どうやって使うの?という話。最初はenchant.jsをCommonJS/Modulesに合うように書き変えなきゃダメだと思っていたんですが、そんなことはないんですね。これは便利。 何が嬉しいの? 開発時にはゲームを複数のJSファイルに分割できるというメリットを、公開時にはゲームプレイに必要なダウンロード回数を減らせるというメリットを得られます。 Why Web Modules? 複雑なゲームじゃないしべつにgame.jsひとつで充分ですという場合には、はっきり言って不要なモノです。しかし長々と開発してたらクラス数が10を超えてきて超長いスクリプトになっちまったぜウォォという場合には、遠慮なくコードを分割統治できるというメリットは大きいでしょう。 enchant.jsとgame.jsを読み込む まずはrequir
In my previous post, I covered the structure of a Backbone.js application using RequireJS. The next thing (or if you are a TDD fan, the first thing) we do is to run some tests on it. According to Coda Hale: Writing tests for your code may not reduce the number of bugs, but it will make fixing the bugs you inevitably find easier. Obviously, we can take advantage of the AMD architecture, to help us
Writing Modular JavaScript With AMD, CommonJS & ES HarmonyのModules With Deferred Dependenciesが便利なので活用してる。 初期化処理が非同期処理でrequireしてきても即使えるとは限らない場合に使う。 モジュール側ではモジュールそのものではなくてpromiseを返しておいて、モジュールの実体が完成したらresolveで渡す。 使う側はrequireしてきたpromiseのthenメソッドのcallbackでモジュールの実体を受け取って使う。 // 何らかの非同期処理を経て初期化されるモジュール define('someModule',['jquery'],function($){ var dfd = $.Deferred(); setTimeout(function(){ // モジュールとして実際
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く