diff --git a/lib/liquid.rb b/lib/liquid.rb
index af38cd4..d6334ec 100644
--- a/lib/liquid.rb
+++ b/lib/liquid.rb
@@ -73,6 +73,3 @@ require 'liquid/token'
# Load all the tags of the standard library
#
Dir[File.dirname(__FILE__) + '/liquid/tags/*.rb'].each { |f| require f }
-
-require 'liquid/profiler'
-require 'liquid/profiler/hooks'
diff --git a/lib/liquid/profiler.rb b/lib/liquid/profiler.rb
index 912804d..67ad6fa 100644
--- a/lib/liquid/profiler.rb
+++ b/lib/liquid/profiler.rb
@@ -1,9 +1,12 @@
+require 'liquid/profiler/hooks'
+
module Liquid
# Profiler enables support for profiling template rendering to help track down performance issues.
#
- # To enable profiling, pass the profile: true option to Liquid::Template.parse. Then, after
- # Liquid::Template#render is called, the template object makes available an instance of this
+ # To enable profiling, first require 'liquid/profiler'.
+ # Then, to profile a parse/render cycle, pass the profile: true option to Liquid::Template.parse.
+ # After Liquid::Template#render is called, the template object makes available an instance of this
# class via the Liquid::Template#profiler method.
#
# template = Liquid::Template.parse(template_content, profile: true)
diff --git a/lib/liquid/template.rb b/lib/liquid/template.rb
index 8862564..e86dfb5 100644
--- a/lib/liquid/template.rb
+++ b/lib/liquid/template.rb
@@ -250,6 +250,8 @@ module Liquid
def with_profiling
if @profiling && !@options[:included]
+ raise "Profiler not loaded, require 'liquid/profiler' first" unless defined?(Liquid::Profiler)
+
@profiler = Profiler.new
@profiler.start
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 75d5491..438f075 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -5,6 +5,7 @@ require 'spy/integration'
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
require 'liquid.rb'
+require 'liquid/profiler'
mode = :strict
if env_mode = ENV['LIQUID_PARSER_MODE']